package com.edu.test;

import com.edu.bean.Book;
import com.edu.bean.Grade;
import com.edu.mapper.BookMapper;
import com.edu.mapper.GradeMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

/*
 * @Author:mx
 * @Date:2025/9/30-14:26:45
 */
public class MyTest02 {

    private SqlSession session ;

    @Before
    public void init() throws IOException {
        String path = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(path);
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        session = sessionFactory.openSession();
    }
    @Test
    public void test01(){
        BookMapper bookMapper = session.getMapper(BookMapper.class);
        Book book = bookMapper.selectBookById(1);
        System.out.println(book);

    }

    

}
